package com.api_gateway.controller;

import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.Map;

@RestController
public class FallbackController {
    
    @RequestMapping("/fallback")
    public ResponseEntity<Map<String, Object>> fallback() {
        Map<String, Object> response = new HashMap<>();
        response.put("code", 503);
        response.put("msg", "服务暂时不可用，请稍后重试");
        response.put("timestamp", System.currentTimeMillis());
        return ResponseEntity.status(503).body(response);
    }
    
    @RequestMapping("/fallback/user-service")
    public ResponseEntity<Map<String, Object>> userServiceFallback() {
        Map<String, Object> response = new HashMap<>();
        response.put("code", 503);
        response.put("msg", "用户服务暂时不可用，请检查服务注册状态");
        response.put("timestamp", System.currentTimeMillis());
        return ResponseEntity.status(503).body(response);
    }
}